home *** CD-ROM | disk | FTP | other *** search
- Path: hellwig.a2i!hellwig
- From: Oliver Hellwig <hellwig@rahul.net>
- Newsgroups: comp.lang.c++,comp.lang.c,comp.os.ms-windows.programmer.misc
- Subject: Re: fastest code
- Date: 11 Apr 1996 16:33:59 GMT
- Organization: a2i network
- Message-ID: <4kjc9n$f7j@samba.rahul.net>
- References: <316112A2.7D37@public.sta.net.cn> <4kgbmj$j3j@solutions.solon.com> <4kghs7$250@news1.mnsinc.com> <4kgu7g$n9a@solutions.solon.com>
- NNTP-Posting-Host: waltz.rahul.net
- NNTP-Posting-User: hellwig
-
- In article <4kgu7g$n9a@solutions.solon.com>,
- Peter Seebach <seebs@solon.com> wrote:
- >In article <4kghs7$250@news1.mnsinc.com>,
- >Szu-Wen Huang <huang@mnsinc.com> wrote:
- >>Peter Seebach (seebs@solutions.solon.com) wrote:
- >>: In article <1996Apr10.110121.6784@friend.kastle.com>,
- >>: Richard Krehbiel <rich@kastle.com> wrote:
- >>: >Oliver Hellwig <hellwig@rahul.net> wrote:
- >>: >> for (i=0; i<16; i++)
- >>: >> prom[i] = prom[i+i];
- >
- >>: HUH? the code as written has a clear effect, which is to shove all of
- >>: the elements of an array over one. It certainly is an optimizer bug.
- >
- >>: Read the code carefully; the 2nd reference to prom[] uses a different
- >>: index into the array. This is not a meaningless statement.
- >
- >>*You* read closely. The second index is "i+i". ;) Okay, so it's a
- >>typo, but one who says "read carefully" is expected to. Cheers.
- >
- >Okay, so the code becomes undefined when i becomes 8.
- >
- >And does nothing when i is 0.
- >
- >But the intervening few cases would be expected to produce
- >assignments.
- >
- >I still think eliminating the assignments is a bug, and that "volatile"
- >should not have any effect, but I'll grant that it's far
- >from the only problem.
- >
- >Wow.
- >
- >I can't read anymore, can I.
-
- I'm sorry that I caused this confusion by leaving out the declaration.
- It is declared as "unsigned char prom[32]". If it were declared
- as "char prom[16]" it would be a broken program. The use of the
- volatile keyword is irrelevant to this problem.
-
- --
- Oliver Hellwig
- hellwig@rahul.net
-